package struts.form;

import java.lang.reflect.Field;

import javax.servlet.http.HttpServletRequest;

/**
 * 创建者 zhuhong  E-mail: zhuhong719@126.com
 * 创建时间：Jul 16, 2014 8:36:33 PM
 * 版本：
 * 类说明：
 * 修改者：
 * 修改时间：Jul 16, 2014 8:36:33 PM
 * 修改说明：
 */
public class FullForm {
	public FullForm(){
		
	}
	
	@SuppressWarnings("unchecked")
	public static ActionForm full(String path,HttpServletRequest request){
		ActionForm actionForm=null;
		try {
			System.out.println(path);
			Class clazz=Class.forName(path);
			actionForm=(ActionForm)clazz.newInstance();
			Field [] filed=clazz.getDeclaredFields();
			for (Field f : filed) {
				f.setAccessible(true);
				f.set(actionForm, request.getParameter(f.getName()));
				f.setAccessible(false);
			}
			System.out.println("信息:Form装载成功!");
		} catch (Exception e) {
			e.printStackTrace();
			System.out.println("严重:Form装载失败!");
		}
		return actionForm;
	}
}
